<template>
	<div class="wechat-bind">
	<h1>seo设置</h1>
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
  <el-form-item label="网站名称" prop="title">
    <el-input v-model="ruleForm.title"></el-input>
  </el-form-item>
  <el-form-item label="关键词" prop="keyword">
    <el-input type="textarea" v-model="ruleForm.keyword"></el-input>
  </el-form-item>
  <el-form-item label="描述" prop="description">
    <el-input type="textarea" v-model="ruleForm.description"></el-input>
  </el-form-item>
  <el-form-item label="备案" prop="icp">
    <el-input type="textarea" v-model="ruleForm.icp"></el-input>
  </el-form-item>
  <el-form-item label="统计" prop="script">
    <el-input type="textarea" v-model="ruleForm.sctipt"></el-input>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
    <el-button @click="resetForm('ruleForm')">重置</el-button>
  </el-form-item>
</el-form>
</div>
</template>
<script>
  export default {
  	name:'site-setting',
    data() {
      return {
        apiUrl:apiUrl,
        ruleForm: {
          title: '',
          keyword: '',
          description: '',
          ipc: '',
          script: '',
        },
        rules: {
          title: [
            { required: true, message: '请输入标题', trigger: 'blur' }
          ]
        }
      };
    },
    mounted () {
      this.$nextTick(function () {
          this.load();//概况
      })
  },
    methods: {
    	//概况数据获取
      load() {
        var url = this.apiUrl+'Site/setting';
          this.$http.get(url)
          .then(function (response) {
            this.ruleForm = response.data;
          })
          .catch(function (response) {
            console.log(response);
          });
      },
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            var url = this.apiUrl+'Site/setting';
            this.$http.post(url, this.ruleForm).then(response => {
              if(response.data.status==1){
                this.$message.success('保存成功');
              }else{
                this.$message.error('保存失败');
              }
            }, response => {
              this.$message.error('保存失败');
              console.log(response);
            });
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      }
    }
  }
</script>


<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
